package com.wtwd.wtwddevice.listener.appMsg;


import com.wtwd.device.annotation.MsgType;
import com.wtwd.device.constant.MsgTypeEnum;
import com.wtwd.device.mqtentity.MessageBase;
import com.wtwd.wtwddevice.listener.deviceServerMsg.handler.IMsgHandler;
import com.wtwd.wtwddevice.model.entity.Device;
import com.wtwd.wtwddevice.service.IAppCommService;
import com.wtwd.wtwddevice.service.IDeviceService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@MsgType(MsgTypeEnum.APP_OFFLINE)
@Component
public class AppOfflineHandlerImpl implements IMsgHandler {


    @Resource
    private IDeviceService deviceService;

    @Resource
    private IAppCommService appCommService;

    @Override
    public void handleMsg(MessageBase messageBase) {
        Device device = deviceService.getDeviceInfoByImei(messageBase.getDeviceKey());
        if (device != null) {
            appCommService.downLine(device.getId());
        }
        return;
    }

}
